<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <!-- 新 Bootstrap 核心 CSS 文件 -->
    <title>忘记密码</title>
    <link href="{{asset('vendor/bootstrap/css/bootstrap.min.css')}}" rel="stylesheet">
    <link rel="stylesheet" href="{{asset('css/buz/style.css')}}" />
    <!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
    <script src="{{asset('js/buz/jquery.min.js')}}"></script>
    <script src="{{asset('js/buz/common.js')}}"></script>
    <script src="{{asset('vendor/bootstrap/js/bootstrapValidator.js')}}"></script>
    <!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
    <script src="{{asset('vendor/bootstrap/js/bootstrap.min.js')}}"></script>
</head>
<body class="bgwhite">
<div class="yhy-header">
    <div class="yhy-wrapper">
        <a href="javascript:;" class="header-logo">
            <img src="{{asset('image/logo.png')}}" />
        </a>
        <div class="header-txt">重置密码</div>
    </div>
</div>
<div class="yhy-loginBody">



    <div class="yhy-wrapper bgwhite mt20">
        @if(count($errors) > 0)
            <div class="alert alert-danger" role="alert">
                <ul>
                    @foreach($errors->all() as $value)
                        <li> {{$value}} </li>
                    @endforeach
                </ul>
            </div>

        @else

        <div class="pwd-box">
            <div class="pwd-title">请重新设置密码</div>
            <div class="pwd-body">
                <form class="form-horizontal" role="form" method="post" action="231" id="setPassword">
                    <input type="hidden" name="token" value="{{$credentials['token']}}">
                    <input type="hidden" name="username" value="{{$credentials['username']}}">
                    <div class="form-group">
                        <label for="firstname" class="col-xs-4 col-sm-2 control-label">新密码：</label>
                        <div class="col-xs-10 col-sm-5 col-md-4 col-lg-4">
                            <input type="password" class="form-control" name="newpwd">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="lastname" class="col-xs-4 col-sm-2 control-label">确认密码：</label>
                        <div class="col-xs-10 col-sm-5 col-md-4 col-lg-4">
                            <input type="password" class="form-control" name="Confirmpwd">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="firstname" class="col-sm-2 control-label"></label>
                        <div class="col-xs-10 col-sm-5 col-md-4 col-lg-4">
                            <button type="button" class="btn btn-primary" id="forgetNext">确定</button>
                        </div>
                    </div>

                </form>

            </div>
        </div>
        @endif()
    </div>
</div>
</body>
<script>
    $('#setPassword').bootstrapValidator({
        message: '这个值没有被验证',
        feedbackIcons: {
            valid: 'glyphicon glyphicon-ok',
            invalid: 'glyphicon glyphicon-remove',
            validating: 'glyphicon glyphicon-refresh'
        },
        submitButtons: 'button[id="forgetNext"]',
        submitHandler: null,
        fields: {
            newpwd: {
                message: '密码还没有验证',
                validators: {
                    notEmpty: {
                        message: '密码不能为空'
                    },
                    stringLength: {
                        min: 6,
                        max: 20,
                        message: '密码只能由6-20位字母、数字和下划线组成'
                    },
                    regexp: {
                        regexp: /^[0-9a-zA-Z_]{1,}$/,
                        message: '密码只能由6-20位字母、数字和下划线组成'
                    }
                }
            },
            Confirmpwd: {
                message: '密码重复还没有验证',
                validators: {
                    notEmpty: {
                        message: '密码重复不能为空'
                    },
                    stringLength: {
                        min: 6,
                        max: 16,
                        message: '密码长度在6到16之间'
                    },
                    identical: {
                        field: 'newpwd',
                        message: '两次密码不同请重新输入'
                    }
                }
            }
        }
    });
    $("#forgetNext").click(function(e){
        var form = $('form#setPassword');
        var bootstrapValidate = form.data('bootstrapValidator');
        bootstrapValidate.validate();
        if (bootstrapValidate.isValid()) {
            $.post('api/auth/modifypwd', form.serialize(), function (data) {
                if (filterAjaxData(data)) {
                    window.location.href = '/modifySuccess';
                }
            })
        }
    });
</script>

</html>
